<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    let num1,num2=0,num3=123,str1='',str2='hello',flag=null 
    let flag1=true,flag2=false
    console.log(Boolean(num1)) //未定义型转布尔型:false
    console.log(Boolean(num2)) //数值e转布尔型: false
    console.log(Boolean(num3)) //非e数值转布尔型:ture
    console.log(Boolean(str1)) //空串转布尔型:false
    console.log(Boolean(str2)) //非字符转布尔型:ture
    console.log(Boolean(flag))//null转布尔型:false
    //Bollean()函数会将任何非空字符串和非零的数值转换为ture.
    //将字符串、0、NAN、undefined和nul1转换为false. 
    console.log('---------未定义转数值------------')
    //未定义转数值
    console.log(Number(num1)) //
    console.log(parseInt(num1)) //
    console.log(parseFloat(num1)) //
    console.log('-------------字符转数值-----------')
    //字符型转数值
    console.log(Number(str1)) //空串转数值
    console.log(parseInt(str1)) //空串转数值
    console.log(parseFloat(str1)) //空串转数值
    console.log(Number(str2)) //非空串转数值
    console.log(parseInt(str2)) //非空串转数值
    console.log(parseFloat(str2)) //非空串转数值 
    console.log('---------------------------------') 
    let str4='4.34hello'
    console.log(Number(str4)) //
    console.log(parseInt(str4)) //
    console.log(parseFloat(str4)) //
    console.log('---------------------------------') 
    let str5='hello4.34'
    console.log(Number(str5)) //
    console.log(parseInt(str5)) //
    console.log(parseFloat(str5)) //
    console.log('---------------------------------') 
    let isNAN
    isNAN-Number(str5)
    console.log(isNAN) //NAN
    console.log(Boolean(isNAN)) //false
    console.log('--------转字符型--------')
    console.log(String(num1)) //
    console.log(num3.toString()) //
    // console,log(num1.tostring())
    //nul1和undefined没有tostring ()方法外，其他数据类型都可以完成字符的转换。
    
    
</script>
</html>